import { useAccount } from "@/stores/account";
import { useCommentTimer } from "@/stores/comment";
import { useSession } from "@/stores/sesstion";
import { defineComponent, ref } from "vue";
import styles from './styles.module.css';
import { showToast } from "@/utils/utils";
import { getUserInfo } from "@/utils/ipc";


export default defineComponent({
    setup(_props, _ctx) {
        const timerStore = useCommentTimer();
        return () => {
            return (
                <div >
                    <el-row class={styles.inputBox}>
                        <el-col span={5} class={styles.inputText}>定时发言内容:</el-col>
                        <el-col span={19} class={styles.text}><el-input placeholder="请输入发言内容" size="small" v-model={timerStore.content}></el-input></el-col>
                    </el-row>
                    <el-row class={styles.inputBox}>
                        <el-col span={10} class={styles.inputText}>
                            <span class="app-text">{timerStore.isLogin ? timerStore.user!.nick : '未登录'}&nbsp;&nbsp;&nbsp;&nbsp;</span>
                            <el-button size="small" type="primary" onClick={async () => {
                                const info = await getUserInfo();
                                timerStore.updateUser({
                                    ...info,
                                });

                            }}>{timerStore.isLogin ? '换个账号' : '立即登录'}</el-button>
                        </el-col>
                        <el-col span={2} class={styles.inputText}>间隔:</el-col>
                        <el-col span={4}><el-input-number max={10} min={1} style="width:100%;" v-model={timerStore.time} size="small" step={1} step-strictly></el-input-number></el-col>
                        <el-col span={3} class={styles.inputText}>&nbsp;&nbsp;秒</el-col>
                        <el-col span={5}><el-button size="small" type="primary" onClick={() => {
                            if (timerStore.isRun) {
                                timerStore.stop();
                            } else {
                                timerStore.start();
                            }
                        }}>
                            {
                                timerStore.isRun ? '停止发言' : '定时发言'
                            }</el-button></el-col>
                    </el-row>
                </div>

            );
        }
    },
});
